Skip to content

Fix ineffective jwt+rotate+!revocable combination - #4013

Open
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-14861
Open

Fix ineffective jwt+rotate+!revocable combination#4013
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-14861

Conversation

@joemahady-comm

Copy link
Copy Markdown
Contributor

Fix: Enforced a constraint that prevents identity zones from configuring JWT-formatted refresh tokens with token rotation unless they are also configured to be revocable.

Details: Added checks in GeneralIdentityZoneConfigurationValidator and OauthEndpointBeanConfiguration. If a token policy specifies refreshTokenRotate=true and refreshTokenFormat="jwt" while jwtRevocable=false, it fails validation and throws an exception, ensuring the system enforces true single-use guarantees.

…le combination ai-assisted=yes

Co-authored-by: Cursor <cursoragent@cursor.com>
@joemahady-comm joemahady-comm changed the title Fix ineffective jwt+rotate+!revocable combination ai-assisted=yes Fix ineffective jwt+rotate+!revocable combination Jul 29, 2026
@duanemay
duanemay requested a review from Copilot July 29, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enforces a safety constraint around refresh-token rotation: identity zones (and the global token policy) can no longer enable JWT-formatted refresh tokens + rotation unless JWT revocation is enabled, preventing configurations that cannot provide true single-use guarantees.

Changes:

  • Added validation in GeneralIdentityZoneConfigurationValidator to reject refreshTokenRotate=true + refreshTokenFormat=jwt when jwtRevocable=false.
  • Added a startup-time guard in OauthEndpointBeanConfiguration#uaaTokenPolicy to reject the same invalid property combination for the UAA/global token policy.
  • Updated/added tests to cover the identity-zone validator behavior and to keep existing refresh-grant tests compatible with the new constraint.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
uaa/src/test/java/org/cloudfoundry/identity/uaa/oauth/UaaTokenServicesTests.java Adjusts test properties to satisfy the new constraint when rotation is enabled with JWT refresh tokens.
server/src/test/java/org/cloudfoundry/identity/uaa/zone/GeneralIdentityZoneConfigurationValidatorTests.java Adds validator tests for invalid/valid combinations of rotate + JWT refresh tokens vs. revocability.
server/src/main/java/org/cloudfoundry/identity/uaa/zone/GeneralIdentityZoneConfigurationValidator.java Enforces identity-zone configuration rejection for rotate+JWT refresh tokens unless revocable.
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/beans/OauthEndpointBeanConfiguration.java Enforces the same constraint at startup for the global/UAA token policy derived from properties.
Comments suppressed due to low confidence (2)

server/src/main/java/org/cloudfoundry/identity/uaa/oauth/beans/OauthEndpointBeanConfiguration.java:703

  • This introduces a new configuration constraint across jwt.token.refresh.rotate, jwt.token.refresh.format, and jwt.token.revocable, but the configuration reference for jwt.token.refresh.rotate doesn’t mention that rotation + JWT refresh tokens requires jwt.token.revocable=true. Please update docs/UAA-Configuration-Reference.md to document the invalid combination and the required setting.
        if (refreshTokenRotate && "jwt".equalsIgnoreCase(refreshTokenFormat) && !jwtRevocable) {
            throw new IllegalArgumentException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
        }

server/src/main/java/org/cloudfoundry/identity/uaa/oauth/beans/OauthEndpointBeanConfiguration.java:703

  • There’s no automated test asserting that the application context fails to start when jwt.token.refresh.rotate=true, jwt.token.refresh.format=jwt, and jwt.token.revocable=false. Adding an ApplicationContextRunner-style test (similar to server/src/test/java/org/cloudfoundry/identity/uaa/UaaPropertiesTest.java) would lock in this behavior and guard against regressions.
        if (refreshTokenRotate && "jwt".equalsIgnoreCase(refreshTokenFormat) && !jwtRevocable) {
            throw new IllegalArgumentException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
        }

Comment on lines 699 to 705
bean.setRefreshTokenRotate(refreshTokenRotate);

if (refreshTokenRotate && "jwt".equalsIgnoreCase(refreshTokenFormat) && !jwtRevocable) {
throw new IllegalArgumentException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
}

return bean;
Comment on lines +52 to +56
if (tokenPolicy.isRefreshTokenRotate() &&
"jwt".equalsIgnoreCase(tokenPolicy.getRefreshTokenFormat()) &&
!tokenPolicy.isJwtRevocable()) {
throw new InvalidIdentityZoneConfigurationException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants